import { request } from '@/api/request';

export interface ClassListSearchParams {
  entId: string;
  trade?: string;
  //type 1课件包2试卷
  type: number;
}

export interface LowerListVo {
  guid: string;
  className: string;
  sort: number;
  num: number;
  picUrl?: string;
}
export interface ClassListItem {
  guid: string;
  className: string;
  sort: 5;
  num?: number;
  picUrl?: string;
  lowerListVo: LowerListVo[];
}
export interface CategoryItem {
  name: string;
  key: string;
  children: CategoryItem[];
  num: number;
  picUrl?: string;
}
export function mapCategory(item: any): CategoryItem {
  return {
    name: item.className,
    key: item.guid,
    children: item.lowerListVo?.map(mapCategory),
    num: item.num,
    picUrl: item.picUrl,
  };
}
/**
 * @desc 资源库类目课件包试卷列表
 */
export const getCategoryList = (params: ClassListSearchParams) =>
  request({
    url: '/safe/api/entPlatform/classPackagePaperList',
    params,
  });
